<template>
  <div>
    <img
      :src="obj.dogImgUrl"
      alt=""
    />
    <p :style="{background:bgColor}" @click="fn">{{obj.dogName}}</p>
  </div>
</template>

<script>
export default {
  name: "MyDog",
  components: {},
  props: {
    obj:{
      type:Object,
      required:true
    }
  },
  data() {
    return {
      bgColor:''
    };
  },
  computed: {},
  watch: {},
  created() {},
  methods: {
    fn() {
      this.bgColor = `rgb(${Math.floor(Math.random()*256)},${Math.floor(Math.random()*256)},${Math.floor(Math.random()*256)})`
      this.$emit('like-event',this.obj.dogName)
    }
  },
};
</script>

<style scoped>
div {
  width: 200px;
  border: 1px solid black;
  text-align: center;
  float: left;
}

div img {
  width: 100%;
  height: 200px;
}
</style>
